const viewerInit = function(){
    const viewer = new Cesium.Viewer('cesiumContainer', {
     
        baseLayerPicker: false,   //图层选择器
        animation: false,   //左下角仪表
        fullscreenButton: false,   //全屏按钮
        geocoder: false,   //右上角查询搜索
        infoBox: false,   //信息框
        homeButton: false,   //home按钮
        sceneModePicker: false,  //3d 2d选择器
        selectionIndicator: false,  //
        timeline: false,   //时间轴
        navigationHelpButton: false,  //右上角帮助按钮
        imageryProvider: new Cesium.TileMapServiceImageryProvider({
          url: Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII"),
        }),
    })
    //浅拷贝
    window.viewer = viewer
    viewer.cesiumWidget.creditContainer.style.display="none";
    viewer.imageryLayers.addImageryProvider(
        new Cesium.WebMapTileServiceImageryProvider({
            url: "http://icenter.geovis.online/tilecache/service/wmts",
            layer: "Global_Image-JPEG-4326",
            style: "default",
            format: "image/jpeg",
            tileMatrixSetID: "EPSG:4326",
            tilingScheme: new Cesium.GeographicTilingScheme()
        })
    )
    // viewer.imageryLayers.addImageryProvider(
    //     new Cesium.WebMapTileServiceImageryProvider({
    //         url: "http://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=19b72f6cde5c8b49cf21ea2bb4c5b21e",
    //         layer: "tdtBasicLayer",
    //         style: "default",
    //         format: "image/jpeg",
    //         tileMatrixSetID: "GoogleMapsCompatible",
    //         show: true
    //     })
    // )
    var labelUrl="http://t0.tianditu.com/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default.jpg"+"&tk="+'19b72f6cde5c8b49cf21ea2bb4c5b21e';
    viewer.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider({
        url:labelUrl,
        layer: "tdtAnnoLayer",
        style: "default",
        maximumLevel:18,//天地图的最大缩放级别
        format: "image/jpeg",
        tileMatrixSetID: "GoogleMapsCompatible",
        show: false
    }));
    //夜间模式
    // viewer.scene.globe.enableLighting = true//必须开启光照效果，
    // var layer = viewer.scene.imageryLayers.addImageryProvider(
    //     new Cesium.SingleTileImageryProvider({
    //         url: './data/images/earth/black.jpg'
    //     })
    // )
    // layer.dayAlpha = 0.0 //白天图层透明值
    // layer.nightAlpha = 1.0 //夜晚图层透明值
    // layer.brightness = 2.5 //图层发光亮度

    //全局初始化点击方法
    const leftClickHandler = new Cesium.ScreenSpaceEventHandler(viewer.canvas)
   
    leftClickHandler.setInputAction(function (movement) {
        const pickedObject = viewer.scene.pick(movement.position)
        // ie中通过GraphicLayer加载的对象可以通过该方法拾取
        // const pickedObject = that.viewer.graphicLayer.pickByCoordinate(movement.position.x, movement.position.y)
        if (Cesium.defined(pickedObject) && Cesium.defined(pickedObject.id) && typeof pickedObject.id.leftClick === 'function') {
            console.log("选中")
            pickedObject.id.leftClick(pickedObject.id)
        } else {
            // if(cp.currentPolygon){
            //     cp.currentPolygon.polygon.extrudedHeight = cp.currentPolygonHeight
            //     cp.currentPolygon.polygon.material = cp.currentPolygonColor
            //     cp.currentPolygon = null;
            // }
        }
    }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
    
   
}
export default  viewerInit;